<script setup lang="ts">
import { ref } from 'vue'
import { getImageUrl } from '@renderer/utils'
const windowStatus = ref<boolean>(false)

/**
 * 窗口操作
 *
 * @param {number} type 0:最小化 1:最大化 2:关闭
 */
const winFunc = (type: number) => {
  switch (type) {
    case 0:
      window.electron.ipcRenderer.send('window-min')
      break
    case 1:
      windowStatus.value = !windowStatus.value
      window.electron.ipcRenderer.send('winsize', windowStatus.value)
      break
    default:
      window.electron.ipcRenderer.send('close-system-setting')
      break
  }
}
</script>
<template>
  <div
    class="title-bar w-full bg-[#fff] flex items-center justify-between h-10 pl-2 rounded overflow-hidden shadow-sm shadow-slate-400"
  >
    <img class="-w-full h-full pt-2 pb-2" :src="getImageUrl('logo', 'png')" alt="logo" />
    <div class="flex items-center h-full">
      <img
        :src="getImageUrl('decrease', 'svg')"
        alt=""
        class="h-full cursor-pointer p-2 hover:bg-[#E5E5E5]"
        title="最小化"
        @click="winFunc(0)"
      />
      <!-- <img
        :src="windowStatus ? getImageUrl('minimization', 'svg') : getImageUrl('maximize', 'svg')"
        alt=""
        class="h-full cursor-pointer p-2 hover:bg-[#E5E5E5]"
        :title="windowStatus ? '还原' : '最大化'"
        @click="winFunc(1)"
      /> -->
      <img
        :src="getImageUrl('close', 'svg')"
        alt=""
        class="h-full cursor-pointer p-2 hover:bg-[#E81123]"
        @click="winFunc(2)"
      />
    </div>
  </div>
</template>
<style lang="scss" scoped>
.title-bar {
  -webkit-app-region: drag;
}
</style>
